<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<form:form commandName="taskMain" cssClass="form-horizontal" role="form" onsubmit="return false">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskName">任务名称</label>
        <div class="col-sm-8">
            <input type="text" name="taskName" id="taskName" readonly value="${taskMain.mainName}"
                   class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" readonly for="content">任务内容</label>
        <div class="col-sm-8">
            <textarea rows="5" id="content" name="content"
                      class="form-control" readonly>${taskMain.content}</textarea>
        </div>
    </div>
    <div class="form-group">

    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" readonly for="timeLimit">任务时限</label>
        <div class="col-sm-3">
            <input type="text" id="timeLimit" name="timeLimit"
                   class="form-control" value="${taskMain.timeLimit}" readonly>
        </div>
        <label class="col-sm-2 control-label no-padding-right" readonly for="fileNumber">文号</label>
        <div class="col-sm-3">
            <input type="text" id="fileNumber" name="fileNumber"
                   class="form-control" value="${taskMain.fileNumber}" readonly>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">任务附件</label>
        <c:if test="${empty taskMain.file}">
            <div class="col-sm-3">
                <input type="text" value="无任务附件" class="form-control" readonly>
            </div>
        </c:if>
        <c:if test="${!empty taskMain.file}">
            <div class="col-sm-3">
                <input type="button" value="下载" onclick="downDetail('${taskMain.file}')"
                       style="width: 100%; height: 32px;"
                       class="btn-large btn-primary"/>
            </div>
        </c:if>
        <label class="col-sm-2 control-label no-padding-right">事项类型</label>
        <div class="col-sm-3">
            <input type="text" categoryId="${taskMain.categoryId}" value="" class="form-control categoryId" readonly/>
        </div>
    </div>
    <c:forEach items="${taskSubList}" var="taskSub" >
        <div class="clearfix">
            <div class="panel panel-default col-sm-8 col-sm-offset-2">
                <div class="panel-heading row taskSubSubName" taskSubSubName="${taskSub.sysId}">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion"
                           href="#collapse${taskSub.sysId}">
                            <p>${taskSub.subName}（点击查看）</p>
                        </a>
                    </h4>
                </div>
                <div id="collapse${taskSub.sysId}" class="panel-collapse collapse">
                    <div class="row">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>城市</th>
                                <th>邮编</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>Tanmay</td>
                                <td>Bangalore</td>
                                <td>560001</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>

    </c:forEach>

    <input type="hidden" name="sysId" id="sysId" value="${taskNew.sysId}">

</form:form>
<script src="<s:url value="/assets/js/chosen.jquery.js"></s:url>"></script>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script src="<s:url value="/assets/js/modal/modal.js"></s:url>"></script>

<script type="text/javascript">
    $('.taskSubSubName').click(function () {
        var $this = $(this);
        var $sysid = $this.attr("taskSubSubName");
        var html = '<thead>\n' +
            '                            <tr>\n' +
            '                                <th>承办单位</th>\n' +
            '                                <th>单位类型</th>\n' +
            '                                <th>任务状态</th>\n' +
            '                                <th>逾期天数</th>\n' +
            '                                <th>任务时限</th>\n' +
            '                            </tr>\n' +
            '                            </thead>';
        $.ajax({
            url: getUrl("taskSubDetail") + $sysid,
            type: 'get',
            async: false,
            success: function (data) {
                var list = data;
                for (var i = 0;i<data.length;i++) {
                    console.log(i);
                    html += "<tr>\n" +
                        "                                <td>"+list[i].deptName+"</td>\n" +
                        "                                <td>"+(list[i].unitType == 1 ? "牵头" : list[i].unitType == 2 ? "主办" : list[i].unitType == 3 ? "协办" : list[i].unitType == 4 ? "分办" : list[i].unitType == 5 ? "独办" : "未知")+"</td>\n" +
                        "                                <td>"+(list[i].type == 0 ? "待签收" : list[i].type == 1 ? "待反馈" : list[i].type == 2 ? "已反馈" : list[i].type == 3 ? "退回重办" : list[i].type == 4 ? "完成" : "未知")+"</td>\n" +
                        "                                <td>"+(list[i].overdueDay==undefined||list[i].overdueDay==null||list[i].overdueDay==false ? "未逾期" : list[i].overdueDay)+"</td>\n" +
                        "                                <td>"+list[i].timeLimit+"</td>\n" +
                        "                            </tr>"
                }
            }
        });
        $this.siblings().children().children().html(html);

    });
    (function () {
        var $categoryId = $('.categoryId').attr('categoryId');
        $.ajax({
            url:getUrl("categoryName")+$categoryId,
            type:"get",
            dataType:'json',
            async:false,
            success:function (data) {
                $('.categoryId').val(data.category)
            }
        })
    })();
</script>
<style>
    .table > thead > tr {
        background: transparent !important;
    }
</style>